package fr.sedoo.sos.domain;

import org.jdom2.output.EscapeStrategy;

public abstract class IsLocalized extends HasId
{
	protected String lat;
	protected String lon;
	protected String alt;
	protected String epsgCode;

	public abstract IsLocalized getContainer();

	public String getLat() 
	{
		if (lat != null)
		{
			return lat;
		}
		else
		{
			if (getContainer() != null)
			{
				return getContainer().getLat();
			}
			else
			{
				throw new IllegalArgumentException("Impossible to compute latitude");
			}
		}	
	}
	
	public void setLat(String lat) {
		this.lat = lat;
	}
	
	public String getLon() {
		if (lon != null)
		{
			return lon;
		}
		else
		{
			if (getContainer() != null)
			{
				return getContainer().getLon();
			}
			else
			{
				throw new IllegalArgumentException("Impossible to compute longitude");
			}
		}	
	}
	public void setLon(String lon) {
		this.lon = lon;
	}
	
	public String getEpsgCode() {
		if (epsgCode != null)
		{
			return epsgCode;
		}
		else
		{
			if (getContainer() != null)
			{
				return getContainer().getEpsgCode();
			}
			else
			{
				throw new IllegalArgumentException("Impossible to compute epsg code");
			}
		}	
	}

	public void setEpsgCode(String epsgCode) {
		this.epsgCode = epsgCode;
	}
	public String getAlt() {
		return alt;
	}
	public void setAlt(String alt) {
		this.alt = alt;
	}

	public String getSrsName()
	{
		return "urn:ogc:def:crs:EPSG::"+getEpsgCode();
	}
}
